using Microsoft.AspNetCore.Mvc;
using Services.Identity.Domain;
using Services.Initial.PublicProject.PublicClass.OutPutModels;
using Services.Initial.PublicProject.PublicMethods;
using SimpleRabbitmq;

namespace Services.Identity.WebApi.Controllers;
[ApiController]
[Route("[controller]/[action]")]
public class RoleManagerController(IDomainService domainService, IEventBus eventBus) : ControllerBase
{
    private readonly IDomainService domainService = domainService;
    private readonly IEventBus eventBus = eventBus;

    [HttpPost]
    public async Task<OutputModel<string>> CreateRole(string roleName)
    {
        var result = await domainService.CreateRoleAsync(roleName);
        return OutPutMethod<string>.Success("操作成功");
    }
    [HttpPost]
    public async Task<OutputModel<string>> DeleteRole(string roleName)
    {
        var result = await domainService.DeleteRoleAsync(roleName);
        return OutPutMethod<string>.Success("操作成功");
    }
    [HttpPost]
    public async Task<OutputModel<string[]>> GetAllRoleNames()
    {
        var result = await domainService.GetAllRoleNamesAsync();
        return OutPutMethod<string[]>.Success(result);
    }

}